//设置cookie
function setCookie(key,val,ops){
    ops = ops || {};
    let p = ops.path ? ";path="+ops.path : ""; //
    let e = "";
    if(ops.expires){
        var d = new Date();
        d.setDate(d.getDate() + ops.expires)
        e = ";expires=" + d;
    }
    document.cookie = `${key}=${val}${p}${e}`;
}
//setCookie();


//console.log(getCookie("数据2"));

//获取cookie
function getCookie(key){
    let strC = document.cookie;
    let arrC = strC.split("; ");
    for(var i=0; i<arrC.length; i++){
        if(arrC[i].split("=")[0] === key){
            return arrC[i].split("=")[1];
        }
    }
    return "";
}


//删除
removeCookie("qwe")
function removeCookie(key,ops){
    ops = ops || {};
    ops.expires = -1;
    setCookie(key,"",ops)
}